#include <bits/stdc++.h>
using namespace std;
const int maxr = 7+2;
const int maxn = 24;
const int C[] = {0, 2, 2, 7, 2, 7, 2, 2};

struct Node{
    bool cm[maxn];
    string str;
//    Node(){memset(cm, false, sizeof(cm)); str.clear();}
};

int cs[maxn];
bool csm[maxn];

void MtoCM(const bool m[maxr][maxr], bool cm[maxn]){
    int t = 0;
    for (int r = 1; r <= 7; ++r) {
        for (int cc = 1; cc <= C[r]; ++cc) {
            int c = cc;
            if(C[r]==2) c = c*2+1;
            cm[t++] = m[r][c];
        }
    }
}

void CMtoM(const bool cm[maxn], bool m[maxr][maxr]){
    int t = 0;
    for (int r = 1; r <= 7; ++r) {
        for (int cc = 1; cc <= C[r]; ++cc) {
            int c = cc;
            if(C[r]==2) c = c*2+1;
            m[r][c] = cm[t++];
        }
    }
}

Node move(Node u, char cmd){
    bool m[maxr][maxr]; memset(m, false, sizeof(m));
    CMtoM(u.cm, m);
    
    int r = 1, c = 1;
    switch(cmd){
        case 'A':{
            r = 1, c = 3;
            break;
        }
        case 'F':{
            r = 7, c = 3;
            break;
        }
        case 'B':{
            r = 1, c = 5;
            break;
        }
        case 'E':{
            r = 7, c = 5;
            break;
        }
        case 'C':{
            r = 3, c = 7;
            break;
        }
        case 'H':{
            r = 3, c = 1;
            break;
        }
        case 'D':{
            r = 5, c = 7;
            break;
        }
        case 'G':{
            r = 5, c = 1;
            break;
        }
        default:break;
    }
    bool t = m[r][c];
    if(cmd == 'A' || cmd == 'B'){
        for (int x = 2; x <= 7; ++x) {
            m[x-1][c] = m[x][c];
        }
        m[7][c] = t;
    }
    if(cmd == 'F' || cmd == 'E'){
        for (int x = 6; x >=1 ; --x) {
            m[x+1][c] = m[x][c];
        }
        m[1][c] = t;
    }
    if(cmd == 'C' || cmd == 'D'){
        for (int y = 6; y >= 1; --y) {
            m[r][y+1] = m[r][y];
        }
        m[r][1] = t;
    }
    if(cmd == 'H' || cmd == 'G'){
        for (int y = 2; y <= 7; ++y) {
            m[r][y-1] = m[r][y];
        }
        m[r][7] = t;
    }

    MtoCM(m, u.cm);
    u.str.push_back(cmd);
    return u;
}

bool check(Node &u){
    bool m[maxr][maxr];
    CMtoM(u.cm, m);
    for (int c = 3; c <= 5; ++c) {
        if(!m[3][c] || !m[5][c]) return false;
    }
    return (m[4][3] && m[4][5]);
}


set<int> s;
bool vis(Node &u){
    int t = 0;
    for (bool i : u.cm) {
        t = t << 1;
        if(i) t |= 1;
    }
    if(!s.count(t)) {s.insert(t); return false;}
    else return true;
}


string bfs(){
    queue<Node> q;
    Node star; star.str = ""; memcpy(star.cm, csm, sizeof(csm));
    s.clear();
    q.push(star);
    while(!q.empty()){
        Node now = q.front(); q.pop();
        if(check(now))
            return now.str;
        if(vis(now)) continue;
        for(char ch = 'A'; ch<='H'; ++ch){
            Node nx = move(now, ch);
            q.push(nx);
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);
    int in;
    while(true){
        int t = 0;
        for (int i = 0; i < maxn; ++i) {
            cin >> in; if(!in) return 0;
            cs[t++] = in;
        }

        int fill; string best; bool first = true;
        for (int i = 1; i <= 3; ++i) {
            for (int j = 0; j < 24; ++j) {
                csm[j] = cs[j] == i;
            }
            string str = bfs();
            if(first) {best = str; first = false; fill = i;}
            else if(str < best) {best = str; fill = i;}
        }
        if(best.empty()) cout << "No moves needed\n";
        else cout << best << "\n";
        cout << fill << "\n";
    }
}